home *** CD-ROM | disk | FTP | other *** search
- Path: ix.netcom.com!news
- From: jlilley@ix.netcom.com (John Lilley)
- Newsgroups: comp.lang.c++
- Subject: Re: Is WATCOM 10.5 a broken compiler or am I stupid?
- Date: 29 Mar 1996 16:47:10 GMT
- Organization: Netcom
- Message-ID: <4jh46e$scq@dfw-ixnews6.ix.netcom.com>
- References: <315A8A29.613B4EBA@rz.tu-ilmenau.de>
- NNTP-Posting-Host: den-co11-03.ix.netcom.com
- Mime-Version: 1.0
- Content-Type: Text/Plain; charset=US-ASCII
- X-NETCOM-Date: Fri Mar 29 10:47:10 AM CST 1996
- X-Newsreader: WinVN 0.99.7
-
- In article <315A8A29.613B4EBA@rz.tu-ilmenau.de>, ai108@rz.tu-ilmenau.de
- says...
- >typedef struct cstringTEMP
- >{
- > char len;
- > char data[255];
- > public:
- > cstringTEMP & operator=(char *);
- >} cstring;
- >
- >AND THIS IS THE CODE I TRIED TO USE:
- >
- > cstring cs="test";
- >
- >
- >IT GAVE THIS ERROR-MESSAGE:
- >Error! E400: (col 13) cannot convert right expression for initialization
- >
- >CHANGING THE LINE ABOVE TO:
- >cstring cs;
- >cs="test";
- >AND THE ERROR WAS NOT LONGER THERE.
-
-
- Writing:
- cstring cs = "test";
- Attempts to construct a cstring using "test" as an argument to
- the constructor. You have no constructor taking (char*), so this
- fails.
-
- Writing
- cstring cs;
- cs = "test";
- Calls the default constructor for cstring, and then uses operator=
- to assign "test" to it.
-
-
- To make
- csstring cs = "test"
- work, add a constructor to cstring
-
- typedef struct cstringTEMP
- {
- char len;
- char data[255];
- public:
- cstringTEMP & operator=(char *);
- --> cstring(const char*s) { strcpy(data, s); len = strlen(s); }
- } cstring;
-
- john lilley
-
-